<?php

/**
 * OrganizationalMemberData form base class.
 *
 * @method OrganizationalMemberData getObject() Returns the current form's model object
 *
 * @package    Wildlive
 * @subpackage form
 * @author     Maximilian Lenkeit <dev@lenki.com>
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseOrganizationalMemberDataForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                     => new sfWidgetFormInputHidden(),
      'member_id'              => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Member'), 'add_empty' => true)),
      'woggle_id'              => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Woggle'), 'add_empty' => true)),
      'age_group_id'           => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AgeGroup'), 'add_empty' => false)),
      'organizational_unit_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('OrganizationalUnit'), 'add_empty' => false)),
      'date_of_joining'        => new sfWidgetFormDate(),
      'date_of_resignation'    => new sfWidgetFormDate(),
      'scarf'                  => new sfWidgetFormInputCheckbox(),
      'created_at'             => new sfWidgetFormInputText(),
      'updated_at'             => new sfWidgetFormInputText(),
      'deleted_at'             => new sfWidgetFormInputText(),
      'created_by'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Creator'), 'add_empty' => true)),
      'updated_by'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Updator'), 'add_empty' => true)),
      'deleted_by'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Deletor'), 'add_empty' => true)),
      'version'                => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'                     => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'member_id'              => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Member'), 'required' => false)),
      'woggle_id'              => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Woggle'), 'required' => false)),
      'age_group_id'           => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AgeGroup'))),
      'organizational_unit_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('OrganizationalUnit'))),
      'date_of_joining'        => new sfValidatorDate(array('required' => false)),
      'date_of_resignation'    => new sfValidatorDate(array('required' => false)),
      'scarf'                  => new sfValidatorBoolean(array('required' => false)),
      'created_at'             => new sfValidatorPass(array('required' => false)),
      'updated_at'             => new sfValidatorPass(array('required' => false)),
      'deleted_at'             => new sfValidatorPass(array('required' => false)),
      'created_by'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Creator'), 'required' => false)),
      'updated_by'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Updator'), 'required' => false)),
      'deleted_by'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Deletor'), 'required' => false)),
      'version'                => new sfValidatorInteger(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'OrganizationalMemberData', 'column' => array('id'))),
        new sfValidatorDoctrineUnique(array('model' => 'OrganizationalMemberData', 'column' => array('member_id'))),
      ))
    );

    $this->widgetSchema->setNameFormat('organizational_member_data[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'OrganizationalMemberData';
  }

}
